NO_COLOR    = \x1b[0m
COMPILE_COLOR    = \x1b[32;01m
LINK_COLOR    = \x1b[31;01m

CAIRO_CFLAGS=`pkg-config --cflags cairo`
CAIRO_LINK=`pkg-config --libs cairo`
RSVG_CFLAGS=`pkg-config --cflags librsvg-2.0`
RSVG_LINK=`pkg-config --libs librsvg-2.0`

LGI_CFLAGS=-I include
LGI_LINK=-l:./liblgi.so

all: cockpit

main.o: main.cpp
	@echo -e '$(COMPILE_COLOR)* Compiling [$<]$(NO_COLOR)'
	g++ $(RSVG_CFLAGS) $(LGI_CFLAGS) -c $<

joystick.o: joystick.cpp
	@echo -e '$(COMPILE_COLOR)* Compiling [$<]$(NO_COLOR)'
	g++ -c $<

peterbus.o: peterbus.cpp
	@echo -e '$(COMPILE_COLOR)* Compiling [$<]$(NO_COLOR)'
	g++ -c $<	

serial.o: serial.cpp
	@echo -e '$(COMPILE_COLOR)* Compiling [$<]$(NO_COLOR)'
	g++ -c $<	

metalwidgets.o: metalwidgets.cpp
	@echo -e '$(COMPILE_COLOR)* Compiling [$<]$(NO_COLOR)'
	g++ -c $(LGI_CFLAGS) $(CAIRO_CFLAGS) $<
	
cockpit: main.o joystick.o metalwidgets.o serial.o peterbus.o
	@echo -e '$(LINK_COLOR)* Building [$@]$(NO_COLOR)'
	g++  -o cockpit joystick.o metalwidgets.o peterbus.o serial.o main.o $(LGI_LINK) $(RSVG_LINK)


clean:
	@echo -e '$(LINK_COLOR)* Cleaning [$@]$(NO_COLOR)'
	rm -rf main.o cockpit
